package com.kcl.dfss;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class ChangePwd1Activity extends Activity implements OnClickListener{

	
	private EditText edit_phone;
	private ImageView clear1;
	private Button btn_next1;
	private LinearLayout changepwd1_back;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_change_pwd1);
		
		edit_phone = (EditText) this.findViewById(R.id.edit_phone);
		clear1 = (ImageView) this.findViewById(R.id.clear1);
		btn_next1 = (Button) this.findViewById(R.id.btn_next1);
		changepwd1_back = (LinearLayout) this.findViewById(R.id.changepwd1_back);
		
		edit_phone.setOnClickListener(this);
		clear1.setOnClickListener(this);
		btn_next1.setOnClickListener(this);
		btn_next1.setEnabled(false);
		changepwd1_back.setOnClickListener(this);
		
		edit_phone.addTextChangedListener(new TextWatcher() {
			
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
				if(edit_phone.getText().length()>0){
					btn_next1.setEnabled(true);
					btn_next1.setBackgroundResource(R.drawable.changepwd_selector);
				}else{
					btn_next1.setEnabled(false);
					btn_next1.setBackgroundResource(R.drawable.changepwd_noclick);
				}
			}
			
			@Override
			public void beforeTextChanged(CharSequence s, int start, int count,
					int after) {
				
			}
			
			@Override
			public void afterTextChanged(Editable s) {
				
			}
		});
	}

	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.clear1:
			edit_phone.getText().clear();
			break;
		case R.id.btn_next1:
			Intent intent = new Intent();
			intent.setClass(ChangePwd1Activity.this, ChangePwd2Activity.class);
			intent.putExtra("phone", edit_phone.getText().toString());
//			intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent);
			finish();
			break;
		case R.id.changepwd1_back:
			finish();
			break;
		}
	}



}
